package com.tech.connect.dialog;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;

import com.ksy.common.dialog.BottomDialog;
import com.tech.connect.R;

public class PublishDialog extends BottomDialog implements View.OnClickListener {
    private PublishListener publishListener;

    public PublishDialog(@NonNull Context context) {
        super(context);
    }

    public PublishDialog(@NonNull Context context, PublishListener publishListener) {
        super(context);
        this.publishListener = publishListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_publish);
        View publishFuWu = findViewById(R.id.publishFuWu);
        View publishLvYou = findViewById(R.id.publishLvYou);
        View publishZhaoBiao = findViewById(R.id.publishZhaoBiao);
        View publishBaoWu = findViewById(R.id.publishBaoWu);
        View close = findViewById(R.id.close);
        publishFuWu.setOnClickListener(this);
        publishLvYou.setOnClickListener(this);
        publishZhaoBiao.setOnClickListener(this);
        publishBaoWu.setOnClickListener(this);
        close.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.close) {
            if (publishListener != null) {
                publishListener.close(PublishDialog.this);
            }
        } if (v.getId() == R.id.publishFuWu) {
            if (publishListener != null) {
                publishListener.publishFuWu(PublishDialog.this);
            }
        } else if (v.getId() == R.id.publishLvYou) {
            if (publishListener != null) {
                publishListener.publishLvYou(PublishDialog.this);
            }
        } else if (v.getId() == R.id.publishZhaoBiao) {
            if (publishListener != null) {
                publishListener.publishZhaoBiao(PublishDialog.this);
            }
        } else if (v.getId() == R.id.publishBaoWu) {
            if (publishListener != null) {
                publishListener.publishBaoWu(PublishDialog.this);
            }
        }
    }

    public interface PublishListener {
        void publishFuWu(PublishDialog dialog);

        void publishLvYou(PublishDialog dialog);

        void publishZhaoBiao(PublishDialog dialog);

        void publishBaoWu(PublishDialog dialog);
        void close(PublishDialog dialog);
    }
}
